﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyLinqHelper;
using Money.Interfaces;
using Money.Entities;

namespace Money.Data
{
    public class UserDAO : LinQDAO<User, MoneyManagerDataContext>, IUserDAO
    {
        public override string GetIdName()
        {
            return UserOrderBy.UserId.ToString();
        }

        public void CreateUser(User item)
        {
            try
            {
                this.CreateItem(item);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void DeleteUser(int id)
        {
            try
            {
                this.DeleteItem(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void UpdateUser(User item)
        {
            try
            {
                this.UpdateItem(item);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public User GetUserById(int id)
        {
            try
            {
                return this.GetById(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<User> GetUsers(string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return this.GetItems(orderBy, orderDirection, page, pageSize,out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public User GetUser(Criteria c)
        {
            try
            {
                return this.GetItem(c);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
